//
//  FQMeViewController.m
//  WeChat
//
//  Created by 方桥 on 16/5/13.
//  Copyright © 2016年 方桥. All rights reserved.
//

#import "FQMeViewController.h"
#import "AppDelegate.h"
#import "XMPPvCardTemp.h"
@interface FQMeViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *avatarImgView;
@property (weak, nonatomic) IBOutlet UILabel *weChatNumberLabel;

@end

@implementation FQMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setRightItem];

    XMPPvCardTemp *myvCard = [FQXmppTool sharedFQXmppTool].vCard.myvCardTemp;
    
    //获取头像
    if (myvCard.photo) {
        self.avatarImgView.image = [UIImage imageWithData:myvCard.photo];
    }
    //设置微信号
    
    self.weChatNumberLabel.text = [@"微信号：" stringByAppendingString:[FQAccount shareAccount].user];

}
-(void)setRightItem
{
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"注销" style:UIBarButtonItemStyleBordered target:self action:@selector(logoutBtnClick)];
    
    self.navigationItem.rightBarButtonItem = item;
}


-(void)logoutBtnClick
{
    //注销
    [[FQXmppTool sharedFQXmppTool] xmppLogout];
    //设置帐号的登录状态为NO
    [FQAccount shareAccount].login = NO;
    [[FQAccount shareAccount] saveToSandBox];
    
    //回到登录控制器
    [UIStoryboard showInitialVCWithName:@"Login"];
}

@end
